package com.cskaoyan.market.intercepter;

import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class CharacterEncodeIntercepter implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        System.out.println("修改字符集");
        request.setCharacterEncoding("utf-8");
        if (!request.getRequestURI().contains("fetch")){
            response.setContentType("text/html;charset=utf-8");
        }
        return true;
    }

}
